package com.cjm.lecode;

import java.util.*;

public class Ti804 {
    public static int two(String[] words) {
        if (words == null || words.length == 0) {
            return 0;
        }
        if (words.length == 1) {
            return 1;
        }
        String[] arr = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};

        Set<String> result = new HashSet<>(words.length);
        for (int i = 0; i < words.length; i++) {
            StringBuilder sb = new StringBuilder();
            String word = words[i];
            int length = word.length();
            for (int y = 0; y < length; y++) {
                char c = word.charAt(y);
                sb.append(arr[c - 'a']);
            }
            result.add(sb.toString());
        }
        return result.size();
    }
    public static int xx(String[] words) {
        if (words == null || words.length == 0) {
            return 0;
        }
        if (words.length == 1) {
            return 1;
        }
        String[] arr = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
        String[] arrA = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};

        Map<String, String> map = new HashMap<>(26);
        for (int i = 0; i < arrA.length; i++) {
            String key = arrA[i];
            String value = arr[i];
            map.put(key, value);
        }

        Set<String> xx = new HashSet<>(words.length);

        for (int i = 0; i < words.length; i++) {
            String arg = words[i];
            char[] chars = arg.toCharArray();
            StringBuilder sb = new StringBuilder("");
            for (int y = 0; y < chars.length; y++) {
                char aChar = chars[y];
                String s = map.get(String.valueOf(aChar));
                sb.append(s);
            }
            xx.add(sb.toString());
        }

        return xx.size();
    }

    public static void main(String[] args) {
        // System.err.println(xx(new String[]{"gin", "zen", "gig", "msg"}));
        System.err.println('d' - 'a');
    }
}
